/* 
 * Shuriken is the legal property of its developers. Please refer to the
 * COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;
using System.Text;
using Shuriken.Core.UI;

namespace Shuriken.Core.UI.StandardUI
{
    public class AttributeItemController : IUIDisplaySlot 
    {
        private TextItemView m_TextPanel;
        protected frmMain m_ParentForm;

        public AttributeItemController(frmMain ParentForm, TextItemView UIControlPanel)
        {
            m_ParentForm = ParentForm;
            m_TextPanel = UIControlPanel;

            Visible = false; 
        }

        #region IUIDisplaySlot Members

        /// <summary>
        /// TAB possible on this slot.
        /// </summary>
        public bool IsTABPossible
        {
            get
            {
                return false; 
            }
        }

        public Shuriken.Core.Ranking.MutableIndexSet HitMask
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        /// <summary>
        /// Search key for the control 
        /// </summary>
        /// <remarks>
        /// Returning the actual text displayed in the control 
        /// </remarks>
        public string SearchKey
        {
            get
            {
                return this.m_TextPanel.TextContet; 
            }
            set
            {
                this.m_TextPanel.TextContet = value; 
            }
        }

        public Shuriken.Core.Store.SortedDisplayItemList DisplayItems
        {
            get { return new Shuriken.Core.Store.SortedDisplayItemList(); }
        }

        public Shuriken.Core.Store.SortedDisplayItemList InitialDisplayItems
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public int SelectedItemIndex
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public bool SelectedSlot
        {
            get
            {
                return m_TextPanel.ControlSelected; 
            }
            set
            {
                ChangeSelectedSlot(value);
            }
        }

        private void ChangeSelectedSlot(bool value)
        {
            if (value)
            {
                m_TextPanel.Show();
            }

            m_TextPanel.ControlSelected = value; 
        }

        public Shuriken.Core.Store.ISearchable SelectedDisplayItem
        {
            get { throw new Exception("The method or operation is not implemented."); }
            set { throw new Exception("The method or operation is not implemented."); }
        }

        /// <summary>
        /// Changes the visibility of the control 
        /// </summary>
        public bool Visible
        {
            get
            {
                return m_TextPanel.Visible;
            }
            set
            {
                m_TextPanel.Visible = value; 
            }
        }

        public bool BackKeyPressed()
        {
            return false; 
            // m_TextPanel.HandleBackKeyPressed(); 
        }

        public void UpdateDisplaySlot(string SearchKey, int CurrentIndex, List<Shuriken.Core.Store.ISearchable> DisplayItems)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        /// <summary>
        /// Selecting the next item
        /// </summary>
        /// <returns>false</returns>
        /// <remarks>
        /// Selecting the next item from details, returning false since this are ignored by the control 
        /// </remarks>
        public bool SelectNextItemFromDetails()
        {
            return false; 
        }

        /// <summary>
        /// Selecting the previous item
        /// </summary>
        /// <returns>false</returns>
        /// <remarks>
        /// Selecting the next item from details, returning false since this are ignored by the control 
        /// </remarks>

        public bool SelectPreviousItemFromDetails()
        {
            return false; 
        }

        /// <summary>
        /// Selecting the current item
        /// </summary>
        /// <returns>false</returns>
        /// <remarks>
        /// Selecting the next item from details, returning false since this are ignored by the control 
        /// </remarks>
        public bool SelectCurrentItemFromDetails()
        {
            return false; 
        }

        /// <summary>
        /// Tells if the Display slot in search mode  
        /// </summary>
        public bool IsInSearchMode
        {
            get
            {
                return false;
            }
        }

        public string DisplayText
        {
            get
            {
                return m_TextPanel.TextContet; 
            }
        }

        /// <summary>
        /// Erasing search key in the slot. 
        /// </summary>
        /// <remarks>
        /// </remarks>
        public void EraseSearchKey()
        {
            // 
        }

        #endregion
    }
}
